Skip to content

Revert "[libFuzzer] always install signal handler with SA_ONSTACK" #153114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 12, 2025

Conversation

randall77
Copy link
Contributor

Reverts #147422

Seems to be causing problems with tracebacks. Probably the trackback code doesn't know how to switch back to the regular stack after it gets to the top of the signal stack.

@llvmbot
Copy link
Member

llvmbot commented Aug 12, 2025

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Keith Randall (randall77)

Changes

Reverts llvm/llvm-project#147422

Seems to be causing problems with tracebacks. Probably the trackback code doesn't know how to switch back to the regular stack after it gets to the top of the signal stack.


Full diff: https://github.com/llvm/llvm-project/pull/153114.diff

1 Files Affected:

  • (modified) compiler-rt/lib/fuzzer/FuzzerUtilPosix.cpp (+4-8)
diff --git a/compiler-rt/lib/fuzzer/FuzzerUtilPosix.cpp b/compiler-rt/lib/fuzzer/FuzzerUtilPosix.cpp
index b1bb1387876e0..ae22ecf108420 100644
--- a/compiler-rt/lib/fuzzer/FuzzerUtilPosix.cpp
+++ b/compiler-rt/lib/fuzzer/FuzzerUtilPosix.cpp
@@ -78,14 +78,10 @@ static void SetSigaction(int signum,
   }
 
   struct sigaction new_sigact = {};
-  // SA_ONSTACK is required for certain runtimes that use small stacks, for
-  // instance the Go runtime.
-  // See https://github.com/golang/go/issues/49075
-  // Address sanitizer also wants SA_ONSTACK, and the fuzzer and sanitizer
-  // often run together.
-  // SA_ONSTACK is a no-op unless someone also calls sigaltstack. That is left
-  // up to code that needs it.
-  new_sigact.sa_flags = SA_SIGINFO | SA_ONSTACK;
+  // Address sanitizer needs SA_ONSTACK (causing the signal handler to run on a
+  // dedicated stack) in order to be able to detect stack overflows; keep the
+  // flag if it's set.
+  new_sigact.sa_flags = SA_SIGINFO | (sigact.sa_flags & SA_ONSTACK);
   new_sigact.sa_sigaction = callback;
   if (sigaction(signum, &new_sigact, nullptr)) {
     Printf("libFuzzer: sigaction failed with %d\n", errno);

@wrotki wrotki self-requested a review August 12, 2025 15:49
Copy link
Contributor

@wrotki wrotki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I asked for this revert, will merge on behalf of @randall77

@wrotki wrotki merged commit 03372c7 into llvm:main Aug 12, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants